-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: provide a simple way to create metaclient #4257
feat: provide a simple way to create metaclient #4257
Conversation
WalkthroughThe change focuses on refactoring and renaming functions related to Changes
Poem
Tip AI model upgrade
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range and nitpick comments (1)
src/frontend/src/instance.rs (1)
135-135
: Add documentation for thecluster_id
variable.The
cluster_id
variable is currently set to0
with a TODO comment. It would be helpful to add documentation explaining why it's reserved and when it should be enabled.let cluster_id = 0; // TODO: jeremy: It is currently a reserved field and has not been enabled. // This variable is reserved for future use when cluster ID functionality is implemented.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- src/cmd/src/datanode.rs (1 hunks)
- src/cmd/src/flownode.rs (1 hunks)
- src/datanode/src/heartbeat.rs (3 hunks)
- src/flow/src/heartbeat.rs (2 hunks)
- src/frontend/src/instance.rs (2 hunks)
- src/meta-client/src/lib.rs (2 hunks)
Additional comments not posted (9)
src/meta-client/src/lib.rs (3)
17-22
: Imports look good.The import statements for
ChannelConfig
,ChannelManager
, andMetaClientBuilder
are necessary for building and configuring the meta client.
63-68
: EnumMetaClientType
is well-defined.The
MetaClientType
enum correctly differentiates between the types of meta clients and includes necessary member IDs.
70-114
: Functioncreate_meta_client
is well-structured.The
create_meta_client
function correctly utilizes theMetaClientType
enum to create and configure meta clients. The use ofChannelConfig
andChannelManager
is appropriate.src/flow/src/heartbeat.rs (2)
32-32
: Imports look good.The import statements for
MetaClientOptions
andMetaClientType
are necessary for creating and configuring the meta client.
238-249
: Functionnew_meta_client
is well-structured.The
new_meta_client
function correctly utilizes thecreate_meta_client
function to create a meta client for the flownode.src/cmd/src/flownode.rs (1)
229-229
: Function call tonew_meta_client
is correct.The
new_meta_client
function call correctly passes the necessary parameters to create a meta client for the flownode.src/datanode/src/heartbeat.rs (2)
28-29
: Imports look good.The import statements for
MetaClientOptions
andMetaClientType
are necessary for creating and configuring the meta client.
345-357
: Functionnew_meta_client
is well-structured.The
new_meta_client
function correctly utilizes thecreate_meta_client
function to create a meta client for the datanode.src/cmd/src/datanode.rs (1)
286-286
: Function call tonew_meta_client
is correct.The
new_meta_client
function call correctly passes the necessary parameters to create a meta client for the datanode.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4257 +/- ##
==========================================
- Coverage 84.97% 84.71% -0.26%
==========================================
Files 1054 1054
Lines 187154 187120 -34
==========================================
- Hits 159033 158523 -510
- Misses 28121 28597 +476 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (10)
- src/cmd/src/datanode.rs (2 hunks)
- src/cmd/src/error.rs (2 hunks)
- src/cmd/src/flownode.rs (2 hunks)
- src/cmd/src/frontend.rs (2 hunks)
- src/datanode/src/datanode.rs (3 hunks)
- src/datanode/src/heartbeat.rs (6 hunks)
- src/flow/src/heartbeat.rs (2 hunks)
- src/frontend/src/instance.rs (2 hunks)
- src/meta-client/src/lib.rs (2 hunks)
- tests-integration/src/cluster.rs (1 hunks)
Files skipped from review as they are similar to previous changes (4)
- src/cmd/src/datanode.rs
- src/cmd/src/flownode.rs
- src/datanode/src/heartbeat.rs
- src/frontend/src/instance.rs
Additional comments not posted (7)
src/meta-client/src/lib.rs (2)
64-69
: EnumMetaClientType
looks good.The enum
MetaClientType
is well-defined and follows Rust's best practices.
73-117
: Ensure proper error handling and logging increate_meta_client
.The function is well-structured, but it would be beneficial to verify that all potential errors are properly handled and logged.
src/cmd/src/error.rs (1)
343-348
: Error variantMetaClientInit
looks good.The error variant
MetaClientInit
is well-defined and follows Rust's best practices.tests-integration/src/cluster.rs (1)
321-324
: Ensure consistent usage ofMetaClientRef
.The update to use
MetaClientRef
looks correct. Verify that theMetaClientRef
usage is consistent across the codebase.Verification successful
Consistent usage of
MetaClientRef
verified.The
MetaClientRef
is used consistently across the codebase in the following locations:
src/datanode/src/heartbeat.rs
src/datanode/src/datanode.rs
src/meta-client/src/lib.rs
The type alias
MetaClientRef
is defined asArc<client::MetaClient>
, ensuring a consistent reference type across the codebase.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify consistent usage of `MetaClientRef`. # Test: Search for `MetaClientRef` usage. rg --type rust 'MetaClientRef'Length of output: 591
src/datanode/src/datanode.rs (3)
37-37
: Import ofMetaClientRef
looks good.The import is necessary for the subsequent changes that utilize
MetaClientRef
instead ofMetaClient
.
158-158
: Update ofmeta_client
field to useMetaClientRef
looks good.This change aligns with the new approach of using
MetaClientRef
and is necessary for the new initialization logic.
174-174
: Update ofwith_meta_client
method to useMetaClientRef
looks good.This change is consistent with the previous updates and necessary for the correct initialization of
MetaClientRef
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/meta-client/examples/lock.rs (6 hunks)
- src/meta-client/src/client.rs (1 hunks)
Additional comments not posted (7)
src/meta-client/examples/lock.rs (5)
Line range hint
53-75
: LGTM!The function
run_normal
correctly uses theMetaClientRef
type formeta_client
.
Line range hint
76-91
: LGTM!The function
run_multi_thread
correctly uses theMetaClientRef
type formeta_client
.
Line range hint
92-107
: LGTM!The function
run_multi_thread_with_one_timeout
correctly uses theMetaClientRef
type formeta_client
.
Line range hint
108-132
: LGTM!The function
run_with_timeout
correctly uses theMetaClientRef
type formeta_client
.
44-44
: Ensure correct usage ofMetaClientRef
.The
meta_client
is now anArc<MetaClientRef>
. Verify that all usages ofmeta_client
correctly handle theArc
type.Verification successful
Ensure correct usage of
MetaClientRef
.The
meta_client
is correctly handled asArc<MetaClientRef>
in the relevant files.
src/meta-client/examples/lock.rs
: Themeta_client
is wrapped inArc
and passed asMetaClientRef
to various functions.src/meta-client/src/lib.rs
: Themeta_client
is returned asArc<MetaClientRef>
from thecreate_meta_client
function.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify correct usage of `meta_client` as `Arc<MetaClientRef>`. # Test: Search for `meta_client` usage. Expect: Correct handling of `Arc<MetaClientRef>`. rg --type rust $'meta_client'Length of output: 18626
Script:
#!/bin/bash # Extract the relevant code snippets from the files of interest # Extract code from src/meta-client/examples/lock.rs echo "Code from src/meta-client/examples/lock.rs:" rg --context 5 'meta_client' src/meta-client/examples/lock.rs # Extract code from src/meta-client/src/lib.rs echo -e "\nCode from src/meta-client/src/lib.rs:" rg --context 5 'meta_client' src/meta-client/src/lib.rsLength of output: 5009
src/meta-client/src/client.rs (2)
216-216
: LGTM!The
MetaClient
struct has been updated to remove theClone
trait, which is consistent with the changes to useMetaClientRef
.
216-216
: Ensure correct handling ofMetaClientRef
in all methods.Verify that all methods in the
MetaClient
implementations correctly handle theMetaClientRef
type.
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
What's changed and what's your intention?
As the title and @coderabbitai said.
Checklist
Summary by CodeRabbit
Refactor
new_metasrv_client
tonew_meta_client
across several modules.MetaClientRef
instead ofMetaClient
.MetaClientType
enum andcreate_meta_client
function to support different meta client configurations.New Features
MetaClientInit
error variant for enhanced error handling.Bug Fixes
MetaClientInit
error variant.